package jia.editor;

import jia.core.InputProcessor;
import jia.core.event.KeypressUiEvent;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class EditorKeyListener extends KeyAdapter{
    protected InputProcessor inputProc;
    protected EditorUi editUi;
    
    /**
     */
    private EditorKeyListener(){
        // GNDN
    }
    
    /**
     * @param inputProc
     */
    public EditorKeyListener(InputProcessor inputProc, EditorUi editUi){
        this.inputProc = inputProc;
        this.editUi = editUi;
    }
    
    /**
     * @see java.awt.event.KeyAdapter#keyTyped(java.awt.event.KeyEvent)
     */
    public void keyPressed(KeyEvent evt){
        switch(evt.getKeyCode()) {
            case KeyEvent.VK_UP:
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_LEFT:
            case KeyEvent.VK_RIGHT:
                KeypressUiEvent uiEvt = new KeypressUiEvent(evt.getKeyCode());
                inputProc.processUiEvent(uiEvt);
                editUi.updateState();
                break;
        }
    }
}
